<?php

namespace App\Repositories;

use App\Interfaces\AdService;

use App\Models\Ad;
use App\Models\AdPosition;

class AdRepository implements AdService
{

    /**
     *
     * 获取广告
     *
     * @param $position_key   广告位置id索引
     * @return mixed    广告集合 AdModel
     */
    public function get($position_key)
    {
        $adPosition = AdPosition::where('position_key', $position_key)->first();

        if (empty($adPosition))

            return;

        $ad = Ad::where('pos_id', $adPosition->pos_id)->orderBy('list_order','asc')->get();

        return $ad;
    }


}